﻿using Cofe.Core.Property;
using Cofe.Core.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cofe.Core.Filter
{
    [EntryFilter("guid")]
    public class GuidEntryFilter : EntryFilterBase
    {
        public GuidEntryFilter(string entryIdStr, string id = "guid")
            : base(entryIdStr, id)
        {
            SupportedMatchType = MatchType.MatchThisEntry;
        }

        public GuidEntryFilter(Guid entryId, string id = "guid")
            : this(entryId.ToString(), id)
        {

        }

        public override MatchType matches(IPropertyHost entry,
            params IOptionFilter[] options)
        {
            string name = Value;
            string idStr = entry.Behaviors.GetProperty(CacheProperties.Id).ValueAs<Guid>().ToString();

            bool match = idStr == Value;

            return match ? MatchType.MatchThisEntry : MatchType.None;


        }

    }
}
